from sklearn import linear_model
import numpy as np


def linear_regression_test():
    reg = linear_model.LinearRegression()
    reg.fit([[0, 0], [1, 1], [2, 2]], [0, 1, 2])

    print(reg.coef_)
    print(reg.intercept_)


def ridge_test():
    reg = linear_model.Ridge(alpha=.5)
    reg.fit([[0, 0], [0, 0], [1, 1]], [0, .1, 1])

    print(reg.coef_)
    print(reg.intercept_)


def ridge_cv_test():
    reg = linear_model.RidgeCV(alphas=np.logspace(-6, 6, 13))
    reg.fit([[0, 0], [0, 0], [1, 1]], [0, .1, 1])

    print(reg.alpha_)


def lasso_test():
    reg = linear_model.Lasso(alpha=0.1)
    reg.fit([[0, 0], [1, 1]], [0, 1])

    print(reg.predict([[1, 1]]))


def logistic_test():
    from sklearn.datasets import load_iris
    X, y = load_iris(return_X_y=True)
    print(X.shape, y.shape)
    print(y)
    clf = linear_model.LogisticRegression(random_state=0, max_iter=200).fit(X, y)

    print(clf.predict(X[:2, :]))
    print(clf.predict_proba(X[:2, :]))
    print(clf.score(X, y))


if __name__ == '__main__':
    # linear_regression_test()
    # ridge_test()
    ridge_cv_test()
    # lasso_test()
    # logistic_test()
